#include <windows.h>


class Tictoc
{
	SYSTEMTIME begin_time_;
public:
	static float DiffBetweenTwoTimes(const SYSTEMTIME& a , const  SYSTEMTIME& b);
	Tictoc();
	void Tic();
	float Toc() const;
	float TocAndTic();
};

template<class T>
class Average {
protected:
	T sum_;
	unsigned count_;
public:
	Average();
	T Avg() const;
	Average<T>& operator<<(const T& v );
	void Insert( const T& v );
	void Clear();
};


class TictocAverage : public Tictoc{
	Average<float> intervals_;
public:
	TictocAverage() {}
	float Toc();
	float TocAndTic();
	float AverageToc() const;
	void Clear();
};


template<class T>
Average<T>::Average(){
	sum_ = 0;
	count_ = 0;
}


template<class T>
T Average<T>::Avg() const {
	return sum_/count_;
}

template<class T>
Average<T>& Average<T>::operator<<(const T& v ){
	sum_+=v;
	count_++;
	return *this;
}

template<class T>
void Average<T>::Insert( const T& v ){
	sum_+=v;
	count_++;
}

template<class T>
void Average<T>::Clear(){
	sum_ = 0;
	count_ = 0;
}

